package com.kinghunt.misp.common.enums.configx;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 配置字段类型枚举
 */
public enum ConfigTypeEnum {
    Integer(1, "Integer", java.lang.Integer.class);

    @Getter
    private Integer code;

    @Getter
    private String desc;

    @Getter
    private Class aclass;

    ConfigTypeEnum(Integer code, String desc, Class aclass) {
        this.code = code;
        this.desc = desc;
        this.aclass = aclass;
    }

    private final static Map<Integer, ConfigTypeEnum> map = new HashMap<>(8);
    static {
        for (ConfigTypeEnum e : ConfigTypeEnum.values()) {
            map.put(e.getCode(), e);
        }
    }

    public static ConfigTypeEnum getByCode(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        return map.get(code);
    }
}
